﻿
$(function () {
    $(window).bind('resize', function () {
        var outsideDiv = this.$(".ui-jqgrid\\ ui-widget\\ ui-widget-content\\ ui-corner-all");
        try {
            var documentWidth = document.body.clientWidth - 43;
            //outsideDiv.width("'" + documentWidth + "'");
            $(outsideDiv).css("width", documentWidth + "px");
        }
        catch (err) {
            // outsideDiv.width($(window).width() - 43);
            $(outsideDiv).css("width", ($(window).width() - 43) + "px");
        }
        $("#jqgrid").setGridWidth($(window).width() - 200);
    }).trigger('resize');

//    $(window).bind('resize', function () {
//        $("#jqgrid").setGridWidth($(window).width() - 200);
//    }).trigger('resize');

});
//end

var _$_CurrRowNum = 15;
var _$_gridInit = {
    init: function () {
        if ($.jgrid) {
            $.jgrid.defaults = $.extend($.jgrid.defaults, {
                datatype: "json",
                autowidth: true,
                height: "auto",
                rownumbers: true,
                shrinkToFit: false,
                jsonReader: {
                    root: "rows",
                    page: "page",
                    total: "total",
                    records: "records",
                    userdata: "userdata",
                    repeatitems: false,
                    id: "0"
                },
                loadui: "block",
                loadtext: "&nbsp;&nbsp;&nbsp;&nbsp;请稍候...&nbsp;&nbsp;&nbsp;&nbsp;",
                mtype: "GET",
                multiboxonly: false,
                sortorder: "desc",
                rowNum: _$_CurrRowNum,
                rowList: [_$_CurrRowNum, _$_CurrRowNum * 2, _$_CurrRowNum * 4],
                viewrecords: true //显示总记录数
            });
        }
    }
};

_$_gridInit.init();